import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import { createApp} from 'vue';
import App from './App.vue';
let app
export function bootstrap() {
    console.log('design 子应用 bootstrap');
}
export function mount(props) {
    console.log('design 子应用 mount', props);
    app = createApp(App);
    props.setGlobalState({
        user: {name: 'admin', id: '2'},
        token: 'xxx-xxx-xxx'
    })
    app.provide('globalActions', {
        onGlobalStateChange: props.onGlobalStateChange,
        setGlobalState: props.setGlobalState
    });
    const container = props?.container 
        ? props.container.querySelector('#subapp-viewport') || props.container
        : '#subapp-viewport';
    app.mount(container);
}
// qiankun 生命周期：卸载
export function unmount() {
    console.log('wiki 子应用 unmount');
    app?.unmount();
    app = null;
}
renderWithQiankun({
    bootstrap,
    mount,
    unmount,
    update: () => {}
});
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
    mount({});
}